package com.cjr.controller;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.HashMap;

/**
 * @Author: chenjianrong
 * @Description:
 * @Data: Create in 15:47 2020/2/2
 * @Modified By:
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    /**
     * 进行用户登录
     * @param session
     * @param username
     * @param password
     * @return
     */
    @PostMapping()
    public HashMap login(HttpSession session, String username, String password) {
        HashMap<String, String> result = new HashMap<>();
        if ("admin".equals(username) && "admin".equals(password)) {
            session.setAttribute("username", username);
            session.setAttribute("password", password);
            result.put("code", "1");
        } else {
            result.put("code", "0");
        }
        return result;
    }
}
